﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Fcdbas.Infrastructure.Querying
{
    /// <summary>
    /// 表示一个过滤条件,最后一个条件应设置为None
    /// </summary>
    [DataContract]
    public class Criterion
    {
        private string propertyName;
        private object value;
        private CriteriaOperator criteriaOperator;

        private QueryOperator queryOperator;
        /// <summary>
        /// 各个查询表达式间的组合操作符
        /// </summary>
        [DataMember]
        public QueryOperator QueryOperator
        {
            get
            {
                return queryOperator;
            }
            set
            {
                queryOperator = value;
            }
        }
        /// <summary>
        /// 属性的值
        /// </summary>
        [DataMember]
        public object Value
        {
            get { return this.value; }
            set { this.value = value; }
        }
        /// <summary>
        /// 要进行的比较操作符
        /// </summary>
        [DataMember]
        public CriteriaOperator CriteriaOperator
        {
            get { return criteriaOperator; }
            set { criteriaOperator = value; }
        }
        /// <summary>
        /// 业务类的属性
        /// </summary>
        [DataMember]
        public string PropertyName
        {
            get { return propertyName; }
            set { propertyName = value; }
        }
        /// <summary>
        /// 条件构造函数
        /// </summary>
        /// <param name="propertyName">属性名称</param>
        /// <param name="value">属性值</param>
        /// <param name="operate">条件操作符</param>
        /// <param name="qoperate">最后一个条件应设置为None</param>
        public Criterion(string propertyName,
            object value, CriteriaOperator operate,QueryOperator qoperate)
        {
            this.propertyName = propertyName;
            this.value = value;
            this.criteriaOperator = operate;
            this.queryOperator = qoperate;
        }
    }
}
